function loadSelecteds(grid) {
	var ids = "";
	for ( var i = 0; i < grid.getStore().getTotalCount(); i++) {
		if (grid.getSelectionModel().isSelected(i)) {
			var id = grid.getStore().getAt(i).get('id');
			ids += id + ",";
		}
	}
	ids = ids.substring(0, ids.length - 1);
	return ids;
}

function selectRow(grid, id) {
	for ( var i = 0; i < grid.getStore().getTotalCount(); i++) {
		if (id == grid.getStore().getAt(i).get('id')) {
			grid.getSelectionModel().selectRow(i, true);
			clicar(-1, id);
			break;
		}
	}
}

function selectRows(grid, rows) {
	for ( var j = 0; j < rows.length; j++) {
		for ( var i = 0; i < grid.getStore().getTotalCount(); i++) {
			if (rows[j] == grid.getStore().getAt(i).get('id'))
				grid.getSelectionModel().selectRow(i, true);
		}
	}
}

function checkedBox(elementCheck, id) {
	if (elementCheck) {
		if (elementCheck.checked == true) {
			document.getElementById(id).value = '1';
		} else {
			document.getElementById(id).value = '0';
		}
	}
}

function buttonSubmitClick() {
	document.getElementById('submit').click();
}

function validateFileExtension(fileName) {
	var exp = /^.*\.(jpg|JPG|bmp|BMP|jpg|JPG|jpeg|JPEG|png|PNG|doc|DOC|docx|DOCX|pdf|PDF)$/;
	return exp.test(fileName);
}

function fileType(file) {
	var expPDF = /^.*\.(pdf|PDF)$/;
	var expDOCX = /^.*\.(docx|DOCX)$/;
	var expDOC = /^.*\.(doc|DOC)$/;
	var expPNG = /^.*\.(png|PNG)$/;
	var expJPEG = /^.*\.(jpeg|JPEG)$/;
	var expJPG = /^.*\.(jpg|JPG)$/;
	var expBMP = /^.*\.(bmp|BMP)$/;

	if (expPDF.test(file))
		return 'PDF';
	if (expDOCX.test(file))
		return 'DOCX';
	if (expDOC.test(file))
		return 'DOC';
	if (expPNG.test(file))
		return 'PNG';
	if (expJPEG.test(file))
		return 'JPEG';
	if (expJPG.test(file))
		return 'JPG';
	if (expBMP.test(file))
		return 'BMP';
}
